#pragma once

#include "highfive/H5File.hpp"

#include "DBManager/IRepository/Input/Element/ICTRIA6Repository.h"
#include "DBManager/Repository/HDF5/Base/MpiRepositoryBase.h"

template <>
inline HighFive::DataType HighFive::create_datatype<SG::DataStructure::FEM::CTRIA6Data> ()
{
    HighFive::CompoundType compoundType = {
        { "EID", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
        { "PID", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
        { "G", HighFive::create_datatype<SG::DataStructure::Common::I64[6]> (), SG::DBManager::FIELD_SIZE, true },
        { "THETA", HighFive::create_datatype<SG::DataStructure::Common::Real> () },
        { "ZOFFS", HighFive::create_datatype<SG::DataStructure::Common::Real> () },
        { "TFLAG", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
        { "T", HighFive::create_datatype<SG::DataStructure::Common::Real[3]> (), SG::DBManager::FIELD_SIZE, true },
        { "MCID", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
        { "DOMAIN_ID", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
    };
    return compoundType;
}
SG_DBMANAGER_HDF5_NAMESPACE_OPEN
class CTRIA6Repository : public ICTRIA6Repository, public MpiRepositoryBase<SG::DataStructure::FEM::CTRIA6Data>
{
  public:
    explicit CTRIA6Repository (HDF5Database& database);

    void InitialDatasetInfo () override;  
    
    constexpr int64_t GetDatasetCacheSize () const override  // TODO(wxc) 后续动态释放
    {
        return 1024 * 1024 * 1024;                           // 1GB
    }
};
;
SG_DBMANAGER_HDF5_NAMESPACE_CLOSE